﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using HalalCheck.DataModels;
using HalalCheck.Services;
using HalalCheck.Utils.HttpClient;
using Newtonsoft.Json;
using Xamarin;
using Xamarin.Forms;

[assembly: Dependency(typeof(LiveMadinaService))]
namespace HalalCheck.Services
{
    public class LiveMadinaService : ILiveMadinaService
    {
        public async Task<string> GetLiveMadinaUrl()
        {
            string url = null;
            try
            {
                HttpResponseMessage res =
                    await
                        WebClient.GetClient()
                            .GetAsync("https://dl.dropboxusercontent.com/u/4492418/livemadina.txt");
                res.EnsureSuccessStatusCode();
                url = await res.Content.ReadAsStringAsync();
            }
            catch (Exception exception)
            {
                Insights.Report(exception);
            }
            return url;  
        }
    }
}
